package com.dd.shop4j.console.order.controller;

import javax.annotation.Resource;

import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.servlet.ModelAndView;

import com.dd.shop4j.common.utils.Constant;
import com.dd.shop4j.console.order.controller.forms.OrderQueryForm;
import com.dd.shop4j.console.order.service.OrderManagerService;
import com.dd.shop4j.sys.service.SysConstantService;

@Controller
@RequestMapping("/admin/order/list")
public class OrderListController {

	@Resource
	public OrderManagerService orderManagerService;
	
	@Resource
	private SysConstantService sysConstantService;
	
	@RequestMapping
	public ModelAndView init(OrderQueryForm order, Integer curpage, Integer pagesize) {
		if (curpage == null || curpage <= 0) {
			curpage = 1;
		}
		if (pagesize == null || pagesize <= 0) {
			pagesize = sysConstantService.getInteger(Constant.PAGE_SIZE_CODE);
		}
		ModelAndView view = new ModelAndView("/admin/order/order_list");
		view.addObject("order", order);
		view.addObject("page", orderManagerService.queryOrderInfoByPage(order, curpage, pagesize));
		return view;
	}

}
